if (priv->image_module == NULL) {
return FALSE;
} else if ((priv->image_module->begin_load == NULL) ||
- (priv->image_module->begin_load == NULL) ||
- (priv->image_module->begin_load == NULL) ||
- (priv->image_module->begin_load == NULL)) {
+ (priv->image_module->stop_load == NULL) ||
+ (priv->image_module->load_increment == NULL)) {
g_warning ("module %s does not support incremental loading.\n", priv->image_module->module_name);
return FALSE;
} else {
g_print ("module loaded: name is %s\n", priv->image_module->module_name);
priv->context = (priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, loader);
+
+ if (priv->context == NULL) {
+ g_warning("Failed to begin progressive load");
+ return FALSE;
+ }
+
retval = (priv->image_module->load_increment) (priv->context, priv->buf, 128);
/* if we had more then 128 bytes total, we want to send the rest of the buffer */
return pixbuf;
}
+
+/**
+ * gdk_pixbuf_new:
+ * @art_pixbuf: A libart pixbuf.
+ *
+ * Creates a &GdkPixbuf; magically sets the ArtPixFormat, rowstride, and creates
+ * the buffer. Use gdk_pixbuf_new_from_data() to do things manually.
+ *
+ * Return value: A newly-created &GdkPixbuf structure with a reference count of
+ * 1. Somewhat oddly, returns NULL if it can't allocate the buffer; this unusual
+ * behavior is needed because images can be very large.
+ **/
+GdkPixbuf *
+gdk_pixbuf_new (gboolean has_alpha, int width, int height)
+{
+ GdkPixbuf *pixbuf;
+
+ g_return_val_if_fail (width > 0, NULL);
+ g_return_val_if_fail (height > 0, NULL);
+
+ pixbuf = g_new (GdkPixbuf, 1);
+ pixbuf->ref_count = 1;
+
+ if (has_alpha) {
+ art_u8* pixels;
+ int rowstride;
+
+ /* FIXME, pick an optimal stride */
+ rowstride = 4*width;
+
+ pixels = art_alloc(rowstride*height);
+
+ if (pixels == NULL) {
+ g_free(pixbuf);
+ return NULL;
+ }
+
+ pixbuf->art_pixbuf = art_pixbuf_new_rgba(pixels, width, height, rowstride);
+ } else {
+ art_u8* pixels;
+ int rowstride;
+
+ /* FIXME, pick an optimal stride */
+ rowstride = 3*width;
+
+ pixels = art_alloc(rowstride*height);
+
+ if (pixels == NULL) {
+ g_free(pixbuf);
+ return NULL;
+ }
+
+ pixbuf->art_pixbuf = art_pixbuf_new_rgb(pixels, width, height, rowstride);
+ }
+
+ return pixbuf;
+
+
+}
+
+
GdkPixbuf *gdk_pixbuf_new_from_art_pixbuf (ArtPixBuf *art_pixbuf);
+/* Create a "blank" pixbuf with an optimal rowstride and a new buffer */
+GdkPixbuf *gdk_pixbuf_new (gboolean has_alpha, int width, int height);
+
/* Simple loading */
GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename);
if (priv->image_module == NULL) {
return FALSE;
} else if ((priv->image_module->begin_load == NULL) ||
- (priv->image_module->begin_load == NULL) ||
- (priv->image_module->begin_load == NULL) ||
- (priv->image_module->begin_load == NULL)) {
+ (priv->image_module->stop_load == NULL) ||
+ (priv->image_module->load_increment == NULL)) {
g_warning ("module %s does not support incremental loading.\n", priv->image_module->module_name);
return FALSE;
} else {
g_print ("module loaded: name is %s\n", priv->image_module->module_name);
priv->context = (priv->image_module->begin_load) (gdk_pixbuf_loader_prepare, loader);
+
+ if (priv->context == NULL) {
+ g_warning("Failed to begin progressive load");
+ return FALSE;
+ }
+
retval = (priv->image_module->load_increment) (priv->context, priv->buf, 128);
/* if we had more then 128 bytes total, we want to send the rest of the buffer */